<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<style>
<!--
.h10{
	height: 10px;
}
-->
</style>
	<div class="m-b-md">
		<div class="h10"></div>
		<form class="form-inline" role="form" id="searchForm" name="searchForm">
			<div class="form-group">
				<label class="control-label">
				<span>活动主题:</span></label>
				<input class="form-control" id="orgName" qt="like" name="partyFormMap.subject">
			</div>
			<div class="form-group">
				<label class="control-label">
				<span>开始时间:</span></label>
				<input class="form-control" id="beginTime" qt="like" name="partyFormMap.startTime">
			</div>
			<div class="form-group">
				<label class="control-label">
				<span>结束时间:</span></label>
				<input class="form-control" id="endTime" qt="like" name="partyFormMap.endTime">
			</div>
			<a href="javascript:void(0)" class="btn btn-default" id="search">查询</a>
		</form>
	</div>
	<header class="panel-heading">
	<div class="doc-buttons">
		<c:forEach items="${res}" var="key">
			${key.description}
		</c:forEach>
	</div>
	</header>
	<div class="table-responsive">
		<div id="paging" class="pagclass"></div>
	</div>
	
<script type="text/javascript">
jeDate.skin("gray")  //调用不同风格的样式  分别有 默认("jedate")、红色("red")、绿色("green")、灰色("gray")、
jeDate({
	dateCell:"#beginTime",  //目标元素。由于jedate.js封装了一个轻量级的选择器，因此dateCell还允许你传入class、tag这种方式 '#id .class'
	format:"YYYY-MM-DD",
	isinitVal:false, //显示时间
	isTime:true, 
    festival: true, //显示节日
	minDate:"1990-01-01",
	choosefun:function(){
		addDetail();
	}
});
jeDate({
	dateCell:"#endTime",  //目标元素。由于jedate.js封装了一个轻量级的选择器，因此dateCell还允许你传入class、tag这种方式 '#id .class'
	format:"YYYY-MM-DD",
	isinitVal:false, //显示时间
	isTime:true, 
    festival: true, //显示节日
	minDate:"1990-01-01",
	choosefun:function(){
		addDetail();
	}
});
var dict = [];
<c:forEach items="${dict }" var="record">
dict.push({'value':'${record.value}','label':'${record.label}'});
</c:forEach>
var pageii = null;
var grid = null;
$(function() {
	grid = lyGrid( {
		pagId : 'paging',
		l_column : [{
			colkey : "id",
			name : "操作",
			width : "110px",
			renderData : function(rowindex,data, rowdata, column) {
				return "<img class='imgbtn' title='活动详情' src='" + rootPath + "/images/findDetail.png' onclick=\"viewFun('"+data+"')\"/>";
			}
		},{
			colkey : "subject",
			name : "活动主题",
			renderData : function(rowindex,data, rowdata, column) {
				return "<span title='"+data+"'>"+data+"</span>";
			}
		},{
			colkey : "openid",
			name : "发起人",
			renderData : function(rowindex,data, rowdata, column) {
				return "<span title='"+data+"'>"+data+"</span>";
			}
		},{
			colkey : "contact",
			name : "联络人",
			renderData : function(rowindex,data, rowdata, column) {
				return "<span title='"+data+"'>"+data+"</span>";
			}
		},{
			colkey : "phone",
			name : "联络电话",
			renderData : function(rowindex,data, rowdata, column) {
				return "<span title='"+data+"'>"+data+"</span>";
			}
		},{
			colkey : "address",
			name : "地址",
			renderData : function(rowindex,data, rowdata, column) {
				return "<span title='"+rowdata.address+"'>"+rowdata.address+"</span>";
			}
		},{
			colkey : "startTime",
			name : "开始时间",
			renderData : function(rowindex,data, rowdata, column) {
				return "<span title='"+new Date(data).format("yyyy-MM-dd hh:mm:ss")+"'>"+new Date(data).format("yyyy-MM-dd hh:mm:ss")+"</span>";
			}
		},{
			colkey : "endTime",
			name : "结束时间",
			renderData : function(rowindex,data, rowdata, column) {
				return "<span title='"+new Date(data).format("yyyy-MM-dd hh:mm:ss")+"'>"+new Date(data).format("yyyy-MM-dd hh:mm:ss")+"</span>";
			}
		}, {
			colkey : "status",
			name : "状态",
			renderData : function(rowindex,data, rowdata, column) {
				var val = "";
				$.each(dict,function(i,e){
					if (e.value == data) {
						val = e.label;
						return false;
					}
				});
				return val;
			}
		}],
		jsonUrl : rootPath + '/party/findByApplyingPage.shtml',
		checkbox : true
	});
	$("#search").click("click", function() {// 绑定查询按扭
		var searchParams = $("#searchForm").serializeJson();// 初始化传参数
		$("input[qt=like]").each(function() {
			if ($(this).val().trim() != "") {
				searchParams[$(this).attr("name")] = "%" + $(this).val().trim() + "%";
			}
		});
		grid.setOptions({
			data : searchParams
		});
	});
	$("#viewFun").click("click", function() {
		viewFun();
	});
	$("#addFun").click("click", function() {
		passFun();
	});
	$("#editFun").click("click", function() {
		rejectFun();
	});
	$("#lyGridUp").click("click", function() {
		lyGridUp();
	});
});
function passFun(cbox) {
	var cbox = grid.getSelectedCheckbox();
	if (cbox == "") {
		layer.msg("请选择活动！！");
		return;
	}
	layer.confirm('确认审核通过？', function(index) {
		var url = rootPath + '/party/pass.shtml';
		var s = CommnUtil.ajax(url, { ids : cbox.join(",") }, "json");
		if (s == "success") {
			layer.msg('操作成功');
			grid.loadData();
		} else {
			layer.msg('操作失败');
		}
	});
}
function rejectFun(cbox) {
	var cbox = grid.getSelectedCheckbox();
	if (cbox == "") {
		layer.msg("请选择活动！！");
		return;
	}
	layer.confirm('确认审核拒绝？', function(index) {
		var url = rootPath + '/party/reject.shtml';
		var s = CommnUtil.ajax(url, { ids : cbox.join(",") }, "json");
		if (s == "success") {
			layer.msg('操作成功');
			grid.loadData();
		} else {
			layer.msg('操作失败');
		}
	});
}
function viewFun(cbox) {
	pageii = layer.open({
		
		title : "查看",
		type : 2,
		area : [ "600px", "550px" ],
		content :rootPath + '/party/viewUI.shtml?id=' +cbox
	});
}
function xianzai(url){
	/* $.ajax({
	type : "POST",
	data : {url:url},
	url : rootPath + '/party/download.shtml',
	dataType : 'json',
	success : function(json) {
	}
}); */
window.open(rootPath + '/party/download.shtml?url='+url);
}
function lyGridUp(cbox) {
	pageii = layer.open({
		title : "新增",
		type : 2,
		area : [ "600px", "75%" ],
		content : rootPath + '/party/editUI.shtml'
	});
}
</script>